#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define WEIGHT 3.0e-23
#define KQ 950

static void calcute_math()
{
	float a, b, c;
	float delta;
	float x1,x2;
	printf("Please enter for a, b, c\n");
	scanf("%f%f%f",&a,&b,&c);
	delta = b*b - 4*a*c;
	if(delta < 0)
	{
		printf("Input error.\n");
		exit(1);
	}
	x1 = (-b + sqrt(delta)) / (2*a);
	x2 = (-b - sqrt(delta)) / (2*a);
	printf("x1 = %f\n",x1);
	printf("x2 = %f\n",x2);
}

static void calcute_area()
{
	float a,b,c;
	float s;
	float area;

	printf("Please enter for a, b, c: \n");
	scanf("%f%f%f",&a,&b,&c);
	if((a + b < c) ||( a + c < b) ||(b + c < a))
	{
		printf("Input error");
		exit(1);
	}
	// 注意：1.0/2 不能写成 1/2 前者计算出来的是0.5 后者计算出来的是 0 后者是取整
	s = 1.0 / 2 * (a + b + c);
	// 编译的时候需要gcc io_task.c -lm 需要链接math库
	area = sqrt(s*(s-a)*(s-b)*(s-c));
	printf("area = %f\n",area);
}

static void calcute_sum()
{
	float num;
	float sum;
	printf("Please input num for water:\n");
	scanf("%f",&num);
	if(num <= 0)
	{
		printf("Input error");
		exit(1);
	}
	sum = num * KQ / WEIGHT;
	printf("sum = %f\n",sum);
	printf("sum = %g\n",sum);
	printf("sum = %e\n",sum);
}

int main()
{
	
	calcute_math();
//	calcute_area();
//	calcute_sum();

	exit(0);
}


